<script>
    function mgrApprove(getId,getId2) {
        $.post("<?= site_url() ?>search_global/approve_manager", {
            cRequestNo : getId,
            cType : getId2,
            cTab : "services"
        },
        function(data) {
            $('#top').html(data);
        });
    }
    function gaApprove(getId,getId3,getId2) {
        $.post("<?= site_url() ?>search_global/approve_ga", {
            cRequestNo : getId,
            cType : getId2,
            pReqForNik : getId3,
            cTab : "services"
        },
        function(data) {
            $('#top').html(data);
        });
    }
    function gaApprove2(getId,getId2) {
        $.post("<?= site_url() ?>search_global/approve_ga", {
            cRequestNo : getId,
            cType : getId2,
            cTab : "services"
        },
        function(data) {
            $('#top').html(data);
        });
    }
    function reqEdit(getId,getId2) {
        $.post("<?= site_url() ?>search_global/edit_req", {
            cRequestNo : getId,
            cType : getId2,
            cTab : "services"
        },
        function(data) {
            $('#top').html(data);
        });
    }
    function reqPrint(getId,getId2) {
        $.post("<?= site_url() ?>search_global/print_req", {
            cRequestNo : getId,
            cType : getId2,
            cTab : "services"
        },
        function(data) {
            $('#top').html(data);
        });
    }
</script>
<div id="tablecontent" class="col-md-12">						
                        <div class="form-group">
                            <div class="table-responsive">
                                <table class="table table-bordered table-condensed table-striped" style="background:#f9f9f9;">
                                    <thead>
                                        <tr>
                                            <th class="tblhead" style="width:5%;text-align:center;">#</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Type</th>
                                            <th class="tblhead" style="width:10%;text-align:center;" colspan="3">Request</th>
                                            <th class="tblhead" style="width:25%;text-align:center;">Description</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Atasan</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">GA Approval</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Closing</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Edit</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Print</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php
                                    if (empty($list_data)) {
                                        ?>
                                        <tr><td colspan="8" style="text-align:center">No Data Available</td></tr>
                                        <?php
                                    } else {
                                        
                                            foreach ($list_data as $row) {
                                                $cRecnum        = $row["RECNUM"];    
                                                $cType  		= $row["TYPE"];
                            					$cRequestNo 	= $row["REQUEST_NO"];
                            					$cRequestUrlGa 	= $row["REQUEST_URL_GA"];
                            					$cReqUrl 		= $row["REQ_URL"];
                            					$cRequestUrl 	= $row["REQUEST_URL"];
                            					$cRequestor 	= $row["REQUESTOR"];
                                                $cRequestorName = $row["REQUESTORNAME"];
                            					$cRequesFor 	= $row["REQUEST_FOR"];
                            					$cDescription 	= $row["DESCRIPTION"];
                            					$cSdate  		= $row["SDATE1"];
                            					$cAtasanNik  	= $row["ATASAN_NIK"];
                            					$cAtasanApp  	= $row["ATASAN_APP"];
                            					$cGaApp  		= $row["GA_APP"];
                            					$cItApp  		= $row["IT_APP"];
                            					$cGaFollowup  	= $row["GA_FOLLOWUP"];
                            					$cPrintDokumen 	= $row["PRINT_DOKUMEN"];
                            					$cReqClosing  	= $row["REQ_CLOSING"];
                                                ?>
                                            <tr>
                                                <td style="font-size:10px;"><?php echo $cRecnum;?></td>
                                                <td style="font-size:10px;"><?php echo $cType;?></td>
                                                <td style="font-size:10px;"><?php echo $cRequestor. " - ".$cRequestorName;?></td>
                                                <td style="font-size:10px;"><?php echo $cRequestNo;?></td>
                                                <td style="font-size:10px;"><?php echo $cSdate;?></td>
                                                <td style="font-size:10px;"><?php echo nl2br($cDescription); ?></td>
                                                <td style="font-size:10px;">
                                                <?php 
                                                    //echo $cAtasanApp." / ".$cAtasanNik;
                                                    //var_dump($cAtasanApp);
                                                    if (empty($cAtasanApp)) {/*
                                    					if($cAtasanNik==$nik || $group == 'ADMIN') {
                                    					   $html_atasan = "<a href=\"javascript:FmLov2('$cRequestUrl$cRequestNo')\"><img src=\"images/confirm.png\" border=0></a>";
                                    					}else {
                                    					   $html_atasan = '-';
                                					    }*/
                                                        //$html_atasan=$cRequestUrl.$cRequestNo;
                                                        ?>
                                                        <button type="button" class="btn btn-primary btn-block" onclick="mgrApprove('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >App</button>
                                                        <?php
                                					} 
                                                    elseif ($cAtasanApp=='N') { 
        				                                //$html_atasan="<img src=\"images_new/ico_cross.gif\" border=0>";
                                                        ?>
                                                        <button type="button" class="btn btn-danger btn-block" disabled="">X</button><?php
                                					} 
                                                    elseif ($cAtasanApp=='Y') { ?>
                                                        <button type="button" class="btn btn-success btn-block" disabled="">V</button>
                                                        <?php
                                					} 
                                                ?>
                                                </td>
                                                <td style="font-size:10px;">
                                                <?php
                                                $html_ga='&nbsp;';
                                                //aktifkan saat ada session group
                            					//if($group == 'ADMIN'){
                                					if(empty($cGaApp)){ //JIKA BELUM DI APPROVE GA
                                    					if($cAtasanApp == 'Y' && $cGaFollowup != 'X'){
                                    					   //$cRequestUrl='./request_ga_app.php?pReqId='
                                    					   //$html_ga="<a href=\"javascript:FmLov2('request_ga_app.php?pReqId=$cRequestNo&pReqForNik=$cRequesFor')\"><img src=\"images/confirm.png\" border=0></a>";
                                                           //echo "A ".$cGaFollowup.">> request_ga_app.php?pReqId=".$cRequestNo."&pReqForNik=".$cRequesFor;
                                                           //JIKA WARNA KUNING, MAKA ADA preqfornik
                                                           ?>
                                                           <button type="button" class="btn btn-warning btn-block" onclick="gaApprove('<?php echo $cRequestNo; ?>','<?php echo $cRequesFor;?>','<?php echo $cType;?>');" >App</button>
                                                            
                                                           <?php
                                    					}
                                                        else if($cAtasanApp == 'Y' && $cGaFollowup == 'X'){
                                    					   //$html_ga="<a href=\"javascript:FmLov2('$cRequestUrlGa$cRequestNo')\"><img src=\"images/confirm.png\" border=0></a>";
                                                           //echo "B ".$cGaFollowup.">> ".$cRequestUrlGa."\\".$cRequestNo;
                                                           ?>
                                                           <button type="button" class="btn btn-primary btn-block" onclick="gaApprove2('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >App</button>
                                                           <?php
                                    					}
                                                        else{
                                    					   ?>-<?php
                                    					}
                                					}
                                                    else{
                                    					if($cGaApp == 'Y'){
                                    					    ?>
                                                            <button type="button" class="btn btn-success btn-block" disabled="">V</button>
                                                            <?php
                                    					}elseif($cGaApp == 'N'){
                                    					    ?>
                                                            <button type="button" class="btn btn-danger btn-block" disabled="">X</button>
                                                            <?php
                                    					}
                                                        //Disable sementara cType, tar kerjain
                                                        /*
                                    					if( $cType == 'LOT PARKIR'){
                                        					$qryx = "select parkird_status from fm_parkir_det where parkird_id='$cRequestNo'";
                                        	                $DB1->parse($qryx);
                                        					$DB1->execute();
                                        					if($q=$DB1->nextrow()){
              		                                            $qParkirdStatus= $q["PARKIRD_STATUS"];
                                        					}
                                        																			
                                        					if($qParkirdStatus == 'Y'){
                                        					   $html_ga.="<a href=\"javascript:FmLov2('parkir_deactivate.php?pParkirdId=$cRequestNo');\"><img src=\"images/confirm.png\" border=0></a>";
                                        					}else{
                                        					   $html_ga.="Deactivated";
                                        					}
                                    					}*/
                                					}
                            					//}else{
                            					//   $html_ga="-";
                            					//}
                                                ?>
                                                </td>
                                                <td style="font-size:10px;">
                                                <?php
                                                    if(!empty($cReqClosing)){
                                                        ?>
                                                        <button type="button" class="btn btn-success btn-block" disabled="">V</button>
                                                        <?php
                                                    }
                                                    else{
                                                        if(!empty($cAtasanApp)) {
                                                            ?>
                                                            <button type="button" class="btn btn-primary btn-block" onclick="reqClosing('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >App</button>
                                                            <?php
        												}
                                                        else{
        													?>
                                                            <button type="button" class="btn btn-warning btn-block" disabled="">App</button>
                                                            <?php
        												}
        											}
                                                ?>
                                                </td>
                                                <td style="font-size:10px;">
                                                <?php
                                                //$html_edit='&nbsp;';
                                                //aktifkan saat ada session group
    					                        //if($nik == $cRequestor || $group == 'ADMIN'){
                                                    if(!empty($cGaApp)){
    												    if($cType == 'MEETING ROOM') {
    													   //$html_edit="<a href=\"javascript:FmLov2('room_edit.php?pRoomId=$cRequestNo');\" alt=\"Cetak Dokumen\"><img src=\"images_new/ico_edit2.gif\" border=0></a>";
                                                           ?>
                                                           MEETING
                                                           <?php
    												    }
                                                        else {
    													   //$html_edit="-";
                                                           ?>
                                                           -
                                                           <?php
    													}
    												}
                                                    else{
    													//$html_edit="<a href=\"$cReqUrl$cRequestNo\" alt=\"Cetak Dokumen\"><img src=\"images_new/ico_edit2.gif\" border=0></a>";
                                                        ?>
                                                        <button type="button" class="btn btn-primary btn-block" onclick="reqEdit('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >Edit</button>
                                                        <?php
    												}
    											//}else{
    											//	$html_edit="-";
    											//}
                                                ?>
                                                </td>
                                                <td style="font-size:10px;">
                                                <?php
                                                if(!empty($cGaApp) && $cGaApp == 'Y'){
                                                    ?>
                                                    <button type="button" class="btn btn-primary btn-block" onclick="reqPrint('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >Print</button>
                                                    <?php
    											}
                                                else{
    											     $html_print="-";
    											}
                                                ?>
                                                </td>
                                            </tr>
                                            <?php
                                            }
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <div id="mypaging">
                                <?php
                                echo $paging;
                                echo $jump_page;
                                echo $ipp;
                                ?>
                            </div>								
                        </div>						
                    </div>